package com.ebupt.common.net.model

sealed class DataResult<out T> {

    /**
     * 成功
     */
    data class Success<out T>(val data:T):DataResult<T>()

    /**
     * 失败
     */
    data class Error(val exception: Exception):DataResult<Nothing>()


    object Loading:DataResult<Nothing>()

    override fun toString(): String {
        return when (this){
            is Success -> "Success[data=$data]"
            is Error -> "Error[exception=$exception]"
            Loading -> "Loading"

        }
    }
}


val DataResult<*>.successed
    get() = this is DataResult.Success&&data!=null